<?php

namespace humhub\modules\api\cccstream;

use Yii;
use humhub\modules\like\models\Like;

class LikeLink extends \yii\web\Controller
{

    /**
     * Return Object LikeInfo
     */
    public static function getLists($object){
        $currentUserLiked = false;

        $likes = Like::GetLikes($object->className(), $object->id);
        foreach ($likes as $like) {
            if ($like->user->id == Yii::$app->user->id) {
                $currentUserLiked = true;
                break;
            }
        }

        return Array(
            'like'  => $currentUserLiked?'unlike':'like',
            'count' => count($likes),
        );
    }
}
?>
